<?php
namespace app\api\controller;

//use app\api\model\ProductCategory;

//use app\api\model\Product;
use app\api\model\Goods;

class GoodsCategory extends Base
{
    // 不需要验证
    protected $excludeValidateCheck = [
        'information'
    ];

    protected $ModelPath = 'GoodsCategory';// 定义自动实例化模型

    public function information(){
        $tops = [];
//        $tops[] = [
//            'id'=>1,
//            'guard_name'=>'全部商品'
//        ];
        $categories = [];
        $category_lists = \app\api\model\GoodsCategory::getList();
        foreach ($category_lists as $category)
        {
            $tops[] = [
                'id'=>$category['id'],
                'guard_name'=>$category['title']
            ];
            $categories[$category['id']] = Goods::getGoodsByCategoryId($category['id']);
        }
        //整理数据
        $data = [
            'main_title'=>'商品分类',
            'tops'=>$tops,
            'categories'=>$categories,

            'title'=>'',
            'unread_message'=>'true',
            'search'=>[
                'enable'=>true,
                'placeholder'=>'',
                'scan'=>true,
                'alias'=>'none',
                'params'=>[]
            ],
            'banners'=>[
                'enable'=>true,
                'lists'=>[
                    [
                        'name'=>'',
                        'img'=>get_oss_url('/static/logos/ysyp.png'),
                        'alias'=>'none',
                        'params'=>[],
                    ],
                ]
            ],
            'ensures'=>[
                'enable'=>true,
                'lists'=>[]
            ],
            'navigations'=>[
                'enable'=>true,
                'lists'=>[
                    [
                        'id'=>0,
                        'name'=>'',
                        'logo'=>get_oss_url('/static/logos/ysyp.png'),
                        'alias'=>'none',
                        'params'=>[],
                    ],
                ]
            ],
            'notices'=>[
                'enable'=>true,
                'text'=>'',
                'alias'=>'none',
                'params'=>[]
            ],
            'thematic'=>[
                'enable'=>true,
                'left'=>[
                    [
                        'title'=>'',
                        'img'=>get_oss_url('/static/logos/ysyp.png'),
                        'alias'=>'none',
                        'params'=>[],
                        'lists'=>[
                            [
                                'code'=>'',
                                'cover'=>'',
                                'title'=>'',
                                'amount'=>0,
                                'market_amount'=>0,
                                'alias'=>'none',
                                'params'=>[],
                            ],
                        ]
                    ],
                ],
                'right'=>[],
            ],
            'activity'=>[
                'enable'=>true,
                'name'=>'',
                'img'=>get_oss_url('/static/logos/ysyp.png'),
                'alias'=>'none',
                'params'=>[],
            ],
            'brand'=>[
                'enable'=>true,
                'title'=>'',
                'more'=>'',
                'alias'=>'none',
                'params'=>[],
                'lists'=>[
                    [
                        'code'=>'',
                        'cover'=>'',
                        'title'=>'',
                        'amount'=>0,
                        'market_amount'=>0,
                        'alias'=>'none',
                        'params'=>[],
                    ],
                ]
            ],
            'recommend'=>[
                'enable'=>true,
                'title'=>'',
                'more'=>'',
                'alias'=>'none',
                'params'=>[],
                'lists'=>[
                    [
                        'code'=>'',
                        'cover'=>'',
                        'title'=>'',
                        'amount'=>0,
                        'market_amount'=>0,
                        'alias'=>'none',
                        'params'=>[],
                    ],
                ]
            ],
            'lists'=>[
                'enable'=>true,
                'title'=>'',
                'filters'=>[]
            ],
        ];

        return showSuccess($data);
    }

    //商品列表
    public function listsInformation(){
//        search: {enable: false, placeholder: '', button: ''},
//        switch: {enable: false, lists: [{text: '', alias: '', sort: false, filters: {}, sort_field: ''}]}
        //整理数据
        $data = [
            'search'=>[
                'enable'=>true,
                'placeholder'=>'',
                'button'=>'',
            ],
            'switch'=>[
                'enable'=>true,
                'lists'=>[
                    [
                        'text'=>'',
                        'alias'=>'',
                        'sort'=>true,
                        'filters'=>[],
                        'sort_field'=>'',
                    ]
                ],
            ],
        ];
        //响应数据
        return showSuccess($data);
    }
}